﻿@using Trust.Casas.Web.Extentions;
@using Trust.Casas.Web.Models;

@model MapData

<div id="@Model.MapName" style="width:600px; height:400px"></div>
<script type="text/javascript">

   $(document).ready(function () {
       require(['Trust.maps'], function (mapmodule) {
           var model = @Html.ToJson(Model);
            var map = Trust.Maps.MapHandlerFactory.create($('#'+model.MapName).get(0), {
                initialPosition: {latitude: model.InitialPosition.Latitude, longitude:model.InitialPosition.Longitude},
                zoom: 15
            });

            for (var i in model.Markers) {
                var marker = new Trust.Maps.MarkerData();
                marker.position = {latitude: model.Markers[i].Latitude, longitude: model.Markers[i].Longitude};
                marker.text = model.Markers[i].Name;
                marker.draggable = true;
                map.markers.add(marker);
            }

        });
    });
</script>
